@(widgets: Seq[Widget], form: Form[WidgetForm.Data], postUrl: Call)(implicit request: MessagesRequestHeader)

  @main("Widgets") {

    <h1>Widgets</h1>

    @* Flash shows updates to a page *@
    @request.flash.data.map{ case (name, value) =>
      <div>@name: @value</div>
    }

    <table>
      <thead>
        <tr><th>Name</th><th>Price</th>
      </thead>
      <tbody>
      @for(w <- widgets) {
        <tr><td>@w.name</td><td>@w.price</td></tr>
      }
      </tbody>
    </table>

    <hr/>

    @* Global errors are not tied to any particular form field *@
    @if(form.hasGlobalErrors) {
      @form.globalErrors.map { (error: FormError) =>
        <div>
          @error.key: @error.message
        </div>
      }
    }

    @helper.form(postUrl) {
      @helper.CSRF.formField

      @helper.inputText(form("name"))

      @helper.inputText(form("price"))

      <button>Create widget</button>
    }
  }
